package lesson.c1;

import java.util.Arrays;

public class Extra {
	
	public void sequence(){
		long[] queue = new long[50];
		queue[0] = 1;
		queue[1] = 1;
		for ( int i = 2 ; i < queue.length; i++){
			queue[i] = queue[i - 2] + queue[i - 1];
		}
		System.out.println(Arrays.toString(queue));
	}
	
	public String searchInString(String str, String search){
		int repeat_num = 0;
		String position = "";
		for(int i = 0; i < str.length(); i++){
			if(str.charAt(i) == search.charAt(0)
					&& i + search.length() <= str.length()){
				int foundIdx = i;
				boolean found = true;
				for(int j = 1; j < search.length(); j++){
					if(str.charAt(i+j) != search.charAt(j)){
						found = false;
						break;
					}
				}
				if(found){
					repeat_num++;
					position+= String.valueOf(foundIdx) + ",";
				}
			}
		}
		System.out.println(repeat_num);
		return position;
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Extra t = new Extra();
		String result = t.searchInString("aaaaaaaa", "aa");
		System.out.println(result);
	}
}
